				<div id="desc" class="box">
					<h4>Agent Info</h4>
					<div class="box_content">
						<h5>PB980-002130</h5>
						<div>
						<table width="100%" >
						<tr>
							<th width="20%">
							<th width="32%">
							<th width="10%">
							<th width="38%">
						</tr>
						<tr><td>Serial No:</td><td>UNbc6-D0490-IEp98-12345</td><td>Tasks:</td> <td>205 total, 1 running, 204 sleeping</td></tr>
						<tr>
							<td>Server IP: </td><td>10.243.118.201</td><td>Cpu:</td>  <td>0.0%user, 0.1%sys, 0.0%nice</td>
						</tr>
						<tr><td>Server Name: </td><td>TPSHA6-D049</td><td>Mem:</td>  <td>16426148k total, 15582396k used</td></tr>
						</table>
						</div>
					</div>
					<div class="modal"></div>
				</div>
				
				<div id="history" class="box">
					<h4>History Chart</h4>
					<div class="box_content">
						<div style="margin: 10px 0">
							<script src="js/highcharts.src.js"></script><script src="js/exporting.js"></script>
							<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
						</div>
					</div>
					<div class="modal"></div>
				</div>
				
				<?php 
				try {
					$m = new Mongo('10.243.118.141');
				} catch ( MongoConnectionException $e ) {
					echo '<p class="red">Couldn\'t connect to mongodb, is the "mongo" process running?</p>';
					exit();
				}
				$c = $m->selectDB('test')->selectCollection('system_log_data');
				$fields = array('time_stamp', 'VALUE');
				$criteria = array('COMP' => 'CPU', 'TYPE' => 'usage');
				//var_dump($criteria);
				
				$sort = array('time_stamp' => -1);
				
				$cursor = $c->find($criteria, $fields)->sort($sort)->limit(8);
				$category = array();
				$cpu_array = array();
				foreach ($cursor as $obj) {
					$category[] = date('h:i:s',$obj['time_stamp']->sec);
					$cpu_array[] = floatval($obj['VALUE']);
				}
				$category = array_reverse($category);
				$cpu_array = array_reverse($cpu_array);
				//var_dump($cursor->count(true));
				
				
				$criteria = array('COMP' => 'System Memory', 'UNIT' => 'MB');
				$cursor = $c->find($criteria, $fields)->sort($sort)->limit(8);
				$mem_array = array();
				foreach ($cursor as $obj) {
					$mem_array[] = floatval($obj['VALUE']);
				}
				$mem_array = array_reverse($mem_array);
				
				//var_dump($category);
				//var_dump($cpu_array);
				//var_dump($mem_array);
				?>
				
				<script>
					$(function() {
						var options = {
							chart: {
								renderTo: 'container',
								zoomType: 'xy'
							},
							title: {
								text: 'Agent Process Status'
							},
							subtitle: {
								text: 'Performance'
							},
							xAxis: [{
								//categories: ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25',
								//	'09:30', '09:35', '09:40', '09:45', '09:50', '09:55']
								categories: <?php echo json_encode($category)?>
							}],
							yAxis: [{ // Primary yAxis
								labels: {
									formatter: function() {
										return this.value +'%';
									},
									style: {
										color: '#89A54E'
									}
								},
								title: {
									text: 'Cpu Usage(%)',
									style: {
										color: '#89A54E'
									}
								}
							}, { // Secondary yAxis
								title: {
									text: 'UsedMemory',
									style: {
										color: '#4572A7'
									}
								},
								labels: {
									formatter: function() {
										return this.value +' MB';
									},
									style: {
										color: '#4572A7'
									}
								},
								opposite: true
							}],
							tooltip: {
								formatter: function() {
									return ''+
										this.x +': '+ this.y +
										(this.series.name == 'UsedMemory' ? ' MB' : '%');
								}
							},
							legend: {
								layout: 'vertical',
								align: 'left',
								x: 80,
								verticalAlign: 'top',
								y: 0,
								floating: true,
								backgroundColor: '#FFFFFF'
							},
							series: [{
								name: 'UsedMemory',
								color: '#4572A7',
								type: 'column',
								yAxis: 1,
								data: <?php echo json_encode($mem_array)?>

							}, {
								name: 'Cpu Usage(%)',
								color: '#89A54E',
								type: 'spline',
								data: <?php echo json_encode($cpu_array)?>
							}]
						};
						
						chart = new Highcharts.Chart(options);
					});
				</script>